﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DSLisp.Runtime;
using System.Threading;
using System.Diagnostics;

namespace LispConsole
{
    class Program
    {
        static Engine engine = new Engine();
        static string code = @"


(= fibonacci (fn (n)
		(if (< n 2) n
			(+ (fibonacci (- n 1)) (fibonacci (- n 2))))))

(to i 20 
	(prl (fibonacci i)))


";

        static void Main(string[] args)
        {
            engine.Print += new Print(engine_Print);
            engine.Parse(code);
          //  engine.UseCallStack = true;

            Stopwatch sw = new Stopwatch();
            sw.Start();
            engine.Execute();
            sw.Stop();
            Console.WriteLine ("time elapsed {0}", sw.Elapsed);

            Console.ReadLine();
        }

        static void engine_Print(string text)
        {
            Console.WriteLine(text);
        }

        
    }
}
